package com.cong.websocketdemo.controller;

import com.cong.websocketdemo.config.ResultHandler;
import com.cong.websocketdemo.utils.Result;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @author cong
 * @since 2021/11/18 18:03
 */
@Slf4j
@RestController
@RequestMapping("log")
public class LogCpntroller {

    @Autowired
    private ResultHandler resultHandler;

    @SneakyThrows
    @GetMapping
    public void test(){
        for (int i = 0; i < 100; i++) {
            log.info("test"+i);
            resultHandler.add(String.format("我是第%s消息",i));
            TimeUnit.SECONDS.sleep(1);
        }
    }
}
